﻿using System;
using System.Linq;
using System.Web;
using System.Data;
using System.Text.RegularExpressions;//引入正则表达式命名空间
using System.Text;

namespace msBsc.WebUi
{
    public partial class mfShopCollect : msBsc.Cls.mbPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindControls();
                ShowData();
            }
        }

        private void BindControls()
        {
            if (!IsPostBack)
            {
            }
        }

        private void ShowData()
        {
            oGoodsSearch = new AppLogic.DataAlc.GoodsSearch(HttpUtility.UrlDecode(this.Request.QueryString.ToString()), "0");
            this.ExecJScript("$('#txtQuery').val('" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(oGoodsSearch.GetQueryStr("", "")) + "');");
            //LoadTopForm();
            //LoadGoodsList("", "", "");
        }

        public string GetTopFormJavaScript()
        {
            System.Text.StringBuilder sbJson = new StringBuilder();
            string strf = oGoodsSearch.dicQuery.ContainsKey("f") ? oGoodsSearch.dicQuery["f"] : "";
            sbJson.Append("{");
            sbJson.Append("\"f\":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(strf) + "\"");
            sbJson.Append(",\"query\":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(oGoodsSearch.GetQueryStr("", "")) + "\"");
            sbJson.Append(",\"nav_rows\":" + oGoodsSearch.GetSelectedLinkJson());
            sbJson.Append(",\"form_rows\":" + oGoodsSearch.GetFilterDataJson());
            sbJson.Append("}");
            return " <script type=\"text/javascript\">var topFormData=" + sbJson.ToString() + "</script>";
        }

        public string GetGoodsListJavaScript()
        {
            return " <script type=\"text/javascript\">var goodsListData=" + oGoodsSearch.GetGoodsList("", "", "") + "</script>";
        }
        private msBsc.AppLogic.DataAlc.GoodsSearch oGoodsSearch;
//        public void LoadTopForm()
//        {
//            System.Text.StringBuilder sbJson = new StringBuilder();
//            string strf = oGoodsSearch.dicQuery.ContainsKey("f") ? oGoodsSearch.dicQuery["f"] : "";
//            sbJson.Append("{");
//            sbJson.Append("\"f\":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(strf) + "\"");
//            sbJson.Append(",\"query\":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(oGoodsSearch.GetQueryStr("", "")) + "\"");
//            sbJson.Append(",\"nav_rows\":" + oGoodsSearch.GetSelectedLinkJson());
//            sbJson.Append(",\"form_rows\":" + oGoodsSearch.GetFilterDataJson());
//            sbJson.Append("}");

//            //            this.ExecJScript(@"debugger;
//            //");
//            this.ExecJScript(@" var data= " + sbJson.ToString() + @" ; 
//doBoundTopForm( data,'');");
//        }
        public void LoadGoodsList(string CurrPageNum, string strPageRowsCount, string strSort)
        {
            this.ExecJScript(@" var data= " + oGoodsSearch.GetGoodsList(CurrPageNum, strPageRowsCount, strSort) + @" ; 
                doBoundGoodsList( data,'');");
        }

        public override void DoAction()
        {
            if (this.strAction == "loadBrandlistdata")
            {
                //this.ExecJScript("loadSetBrand('" + this.GetParamHtValue("HOT_LEVEL") + "','" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(LoadBrandListContent(this.GetParamHtValue("HOT_LEVEL"), 4).ToString()) + "');");
            }
        }
    }
}